import os
import time
#1. The files to be stored are sprecified in a list.#
def path():
    file = input('paste file path here: ') #this allows the user to input the directory path
source = [path()]  #this is a basic parameter that should not be hardcoded but should be an argument

#2. We backup the files into a main directory.#
def target():
    location = input('copy backup location here: ') #this allows the user to input the location for the backup
target_dir = target() #this is a basic parameter that should not be hardcoded but should be an argument

#3. We store the backup as a zip file
#4. The current date is the name of the file in the subdirectory.
#Kayode:yous should check if input and output directories exist before proceeding
today = str(target_dir) + os.sep + time.strftime('%Y%m%d')

#the current time is the name of the zip archive
now = time.strftime('%H%M%S')

#This allows the user to input a comment as name of zip file.
comment = input('Enter a comment:> ')
if len('comment') == 0: #this checks if there is a comment
    target = today + os.sep + now + '.zip'
else:
    target = today + os.sep +now + '-' + comment.replace(' ', '_') + '.zip'	
	#1. What if my comment contains any of the following !@#$% or other characters not allowed as file name?
	#2. What is the length of the comment is longer than allowed file name length? It might be better to 
	#  a. Create a file and save the comment in it.
	#  b. include something(e.g."-comment") in the file name to indicate the existence of a comment file.

# create the subdirectory if it's not created already.
if not os.path.exists(today):
    os.mkdir(today) # to make directory
    print('Successfully created directory', today)

#5. we use the zip command to get the file into a zip  file
zip_command = "zip -r {0} {1}".format(today, ' '.join(source))

#now we run the backup
if os.system(zip_command) == 0:	#In an efficient backup, you would like to save only files that have been changed since last backup. Hence, you might want to search the output directory for the last last back up, get the time it occurred (if it did) and only backup files that have been modified/created since then.
    print('Successful backup to', target)
else:
    print('Backup Unsuccessful')
